package com.fizzkai.p2p.website.controller;

import com.fizzkai.p2p.bussness.domain.BidRequest;
import com.fizzkai.p2p.bussness.query.BidRequestQuery;
import com.fizzkai.p2p.bussness.service.IBidRequestService;
import com.fizzkai.p2p.core.util.Constants;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class InvestController {

    @Autowired
    private IBidRequestService bidRequestService;

    @RequestMapping("/invest")
    public String invest(Integer type, Model model){
        model.addAttribute("type", type);
        return "invest1";
    }
    @RequestMapping("/invest_list")
    public String invest_list(@ModelAttribute("qo") BidRequestQuery qo,Integer currentPage, Model model){
        qo.setPageNum(currentPage);
        qo.setStates(new int[]{ Constants.BIDREQUEST_STATE_BIDDING, Constants.BIDREQUEST_STATE_PAYING_BACK, Constants.BIDREQUEST_STATE_COMPLETE_PAY_BACK});
        PageInfo<BidRequest> pageInfo = bidRequestService.query(qo);
        model.addAttribute("pageInfo", pageInfo);
        return "invest_list2";
    }
}
